<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    要查询天气的地点为:<input type="text" class="content">
    <button>查询</button>
    <div class="datil"></div>
    <script>
        let contentEle = document.querySelector(".content");
        let buttonEle = document.querySelector("button");
        let datilEle = document.querySelector(".datil");
        buttonEle.onclick = function() {
            let val = contentEle.value;
            let a = document.createElement("script");
            a.src=`https://query.asilu.com/weather/baidu?city=${val}&callback=movedata`;
            document.head.appendChild(a);
        }
        function movedata(res){
            datilEle.innerHTML = "";
            console.log(res);
            let arr = res.weather;

            arr.forEach(item=>{
                let pEle = document.createElement("p");
                pEle.innerHTML = item.date+item.weather+item.temp;
                datilEle.appendChild(pEle);
            })
        }
    </script>
</body>
</html>